package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql struct {
		User     string
		Password string
		Host     string
		Port     int
		DataBase string
	}

	Redis struct {
		Addr     string
		PassWord string
		DB       int
	}

	ALiYunSms struct {
		AccessKeyId     string
		AccessKeySecret string
		Endpoint        string
	}
}

var ConfigData AppConfig

func Init() {
	viper.SetConfigFile("../appconfig/config.yaml")

	err := viper.ReadInConfig()
	if err != nil {
		panic("配置文件读取失败")
	}
	err = viper.Unmarshal(&ConfigData)
	if err != nil {
		panic("配置文件解析失败")

	}

	fmt.Println(ConfigData)
}
